package cn.softwin.dao.impl;

import java.sql.*;
import java.util.List;

import cn.softwin.dao.UserDao;
import cn.softwin.pojo.SysUser;
import cn.softwin.utils.JDBCpoolUtils;

public class UserDaoImpl implements UserDao {
	// 操作数据库的dao
	private Connection con = null;
	private Connection con1 = null;
	private Statement stat = null;
	private ResultSet res = null;
	private PreparedStatement pstat = null;
	private PreparedStatement pstat1 = null;

	@Override
	public List<SysUser> sysUsers() {
		return null;
	}

	@Override
	public boolean addUser(SysUser sysUser) {
		return false;
	}

	public boolean selectuser(String user, String pass) {
		Connection con = null;
		PreparedStatement pstat = null;
		ResultSet res = null;
		try {
			con = JDBCpoolUtils.getConnection();
			String sql = "select * from sys_user where user_name=? and user_password=?";
			pstat = con.prepareStatement(sql);
			pstat.setString(1, user);
			pstat.setString(2, pass);
			res = pstat.executeQuery();
			if (res.next()) {
				return true;
			} else {
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			JDBCpoolUtils.close(res, pstat, con);
		}
		return false;
	}
}
